<?php
/*
    GUMUD is Extensible Web-based Multi-User Dungeon Software.

    Copyright (C) 2013  White Rabbit

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
 $itx['user']['lang'] = defLang;
if (isset($_COOKIE['first']) AND isset($_COOKIE['last']) AND isset($_COOKIE['pass'])) {
	if(!preg_match("/(\w)+/",$_COOKIE['first'])) {$itx['user']['user-group'] = "user-guest";
	 }
if(!preg_match("/(\w)+/",$_COOKIE['last'])) {$itx['user']['user-group'] = "user-guest";
	 }
if(!preg_match("/(\w|\d)+/",$_COOKIE['pass'])) {$itx['user']['user-group'] = "user-guest";
	 }
$itx['com-user'][1] = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getuser&firstname=".$_COOKIE['first']."&lastname=".$_COOKIE['last']);
$itx['com-user'][2] = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=validateuser&uuid=".$itx['com-user'][1]."&passhash=".$_COOKIE['pass']);
	if ($itx['com-user'][2] == "validated") {
		
		$itx['user']['avatarFirst'] = $_COOKIE['first'];
		$itx['user']['avatarLast'] = $_COOKIE['last'];
		$itx['user']['pass'] = $_COOKIE['pass'];
		$itx['user']['user-group'] = file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getUserLevel&uuid=".$itx['com-user'][1]);
		$itx['user']['user-info'] = splitUserInfo(file_get_contents("http://".gridURL."/index.php?scripthandshakeID=".scripthandshakeID."&request=getUserInfo&uuid=".$itx['com-user'][1]));
		$itx['user']['lang'] = $itx['user']['user-info']['lang'];

		if(!file_exists(pathprivate."config/languages/".$itx['user']['lang'].".php")) { $itx['user']['lang'] = defLang; }
		include(pathprivate."config/languages/".$itx['user']['lang'].".php");
		$itx['user']['emoticons'] = $itx['user']['user-info']['emoticons'];

		if ((isset($itx['script'])) and ($itx['script'] == "inventorycommandprocess")){
include(pathprivate."includes/inventorycommandparser.php");
}
else {
include(pathprivate."includes/commandparser.php");
}		
if($itx['get']['com'] == "front") {
		$itx['get']['com'] = "user";
		$itx['get']['action'] = "account";
		}
	}
	else {
	$itx['user']['user-group'] = "user-guest";
	}	
}
else {
	$itx['user']['user-group'] = "user-guest";
}
?>
